const { timeHelper, appHelper } = require("../helper");

function execLoop(appName) {
  appHelper.goAutojsThenOpen(appName, 2, 8);
  timeHelper.sleepM(0.5, 3);
}

Wang.main = function (min, appName) {
  min = min || 30;
  var secs = Number(min) * 60;
  var start = Date.now();
  while (true) {
    var hasExec = timeHelper.hasExec(start);
    if (hasExec > secs) {
      console.log(`已经执行了${hasExec}秒，将结束循环`);
      break;
    } else {
      execLoop(appName);
    }
  }
};
